<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
	
	function __construct() {
		parent::__construct();
	
		# Carregando Models
		$this->load->model(
		array(
				'Categoria',
				'Comanda'
			)
		);
	}

	public function index() {
		switch ($this->index->logado()) {
			case 'mesa':
				$aData['categorias'] = $this->Categoria->ler();
				$aData['total'] = $this->Comanda->total($this->session->userdata('login_usuario'));
				$this->index->montarPagina('mesa/mesa_view', $aData);
				break;
			case 'caixa':
				redirect('comandas');
				$this->index->montarPagina('comanda/comanda_view');
				break;
			case 'bar':
				redirect('pedidos/bar');
				$this->index->montarPagina('pedido_bar/pedido_bar_view');
				break;
			case 'cozinha':
				redirect('pedidos/cozinha');
				$this->index->montarPagina('pedido_cozinha/pedido_cozinha_view');
				break;
			case 'administrador':
				$this->index->montarPagina('comanda/comanda_view');
				break;
			default:
				if(isset($_GET['85770ae9def3473f559e0dbe0609060a']) && isset($_GET['e8d95a51f3af4a3b134bf6bb680a213a']) && $_GET['e8d95a51f3af4a3b134bf6bb680a213a'] == 'aberta' && $this->usuario->statusMesa($_GET['85770ae9def3473f559e0dbe0609060a']) == 'fechada') {
					$aLogin['login'] = $_GET['85770ae9def3473f559e0dbe0609060a'];
					$this->index->montarPagina('mesa/senha_view', $aLogin);
				} else if(isset($_GET['85770ae9def3473f559e0dbe0609060a']) && $this->usuario->statusMesa($_GET['85770ae9def3473f559e0dbe0609060a']) == 'aberta') {
					$aData['login'] = $_GET['85770ae9def3473f559e0dbe0609060a'];
					$this->index->montarPagina('mesa/nova_senha_view', $aData);
				} else {
					$this->index->montarPagina('usuario/login_view');
				}
				break;
		}
	}
}

/* End of file home.php */
/* Location: ./application/controllers/home.php */